﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;

namespace Krist_em_up.Music
{
    class Son : GameComponent
    {
        AudioEngine engine;
        WaveBank waveBank;
        SoundBank soundBank;
        protected Song WTTJ, JATF;
        private int randSound = 0;


        public Son(GameStateManager game)
            : base(game)
        {
            engine = new AudioEngine(@"Content\sound\Son.xgs");
            soundBank = new SoundBank(engine, @"Content\sound\Sound Bank.xsb");
            waveBank = new WaveBank(engine, @"Content\sound\Test.xwb");
        }

        public override void Initialize()
        {
            engine.Update();
            WTTJ = Game.Content.Load<Song>("sound/WTTJ");
            JATF = Game.Content.Load<Song>("sound/JATF");
            base.Initialize();

        }

        public void play(string son)
        {
            switch (son)
            {
                case "tir":
                    soundBank.PlayCue("Laser_Shoot");
                    break;
            }
        }

        public override void Update(GameTime gameTime)
        {
            engine.Update();

            base.Update(gameTime);
        }
        public void NextSound()
        {
            randSound++;
            FondMusical();
        }

        public void PrevSound()
        {
            randSound--;
            FondMusical();
        }

        public void FondMusical()
        {
            if ((randSound % 2) == 0)
            {
                MediaPlayer.Play(WTTJ);
            }

            else
            {
                MediaPlayer.Play(JATF);
            }
        }
    }
}
